<?php
require ('../include/init.inc.php');
$tr_id = $tourist_id = $tourist_name = $tourist_type =$tourist_addr=$tourist_pay=$self_drive=$tourist_start_time =$tourist_end_time=$is_pay='';;
extract ( $_REQUEST, EXTR_IF_EXISTS );

Common::checkParam($tr_id);
$orderInfo= TouristOrder::getTouristOrderById($tr_id);
if(empty($orderInfo)){
	Common::exitWithError(ErrorMessage::ORDER_NOT_EXIST,"panel/tourist_orders.php");
}
if (Common::isPost ()) {
	
  if($tourist_id=="" || $tourist_name=="" || $tourist_type ==""|| $tourist_addr=="" || $tourist_pay =="" || $self_drive ==""|| $tourist_start_time=="" || $tourist_end_time ==""){
		
		OSAdmin::alert("error",ErrorMessage::NEED_PARAM);
	}else{
		$update_data = array ('tourist_id' => $tourist_id, 'tourist_name' => $tourist_name ,
				'tourist_type' => $tourist_type, 'tourist_addr' => $tourist_addr , 'tourist_pay' => $tourist_pay ,
				'self_drive' => $self_drive , 'tourist_start_time' => strtotime($tourist_start_time) ,
				 'tourist_end_time' =>strtotime($tourist_end_time), 'is_pay' => $is_pay );
		$result = TouristOrder::updateTouristOrder( $tr_id,$update_data );
		
		if ($result>=0) {
			$current_user=UserSession::getSessionInfo();
			$ip = Common::getIp();
			$update_data['ip']=$ip;
			SysLog::addLog ( UserSession::getUserName(), 'MODIFY', 'TouristOrder' , $tr_id, json_encode($update_data) );
			Common::exitWithSuccess ('更新完成','panel/tourist_orders.php');
		} else {
			
			OSAdmin::alert("error");
		}
	}
}

$group_options=UserGroup::getGroupForOptions();
Template::assign ( 'tourist_conf', $baseConf["touristOrder"] );
Template::assign ( 'orderInfo',$orderInfo );
Template::display ( 'panel/tourist_order_modify.tpl' );